
clear; clc;
%addpath(fullfile(pwd, '..', 'lib'));
 datasetsAio = { 'bbcnewssport_737n_1000d_5c_uni_12k','RELATHE_1427n_4322d_2c_tfidf_uni_12k',...
    'warpPIE10P_210n_2420d_10c_12k','COIL20_1440n_1024d_20c_uni_12k',...
    'UMIST_575n_644d_20c_12k','BASEHOCK_1993n_4862d_2c_tfidf_uni_12k',...
     'leukemia_72n_7070d_2c_12k','ALLAML_72n_7129d_2c_12k',...   
};
                                    
indicator={'acc_jmksc_res','nmi_jmksc_res','purity_jmksc_res'}  
for i1 = 1:length(datasetsAio)
    load(fullfile(pwd, '..', 'data', datasetsAio{i1}));
    load(fullfile(pwd, '..', 'jmksc_res.mat'));
    nRepeat = 1;
        for ind=1:3
    s=eval([indicator{ind}]);
    alphas = s(i1,1); % trade-off
    betas = s(i1,2); % local regularization
    gammas =s(i1,3);
    Ks2 = zeros(size(Ks));
    for i2 = 1:size(Ks,3)
        Ktmp = knorm(Ks(:,:,i2));
        if max(Ktmp(:)) > 1
            Ktmp = Ktmp  / max(Ktmp(:));
        end
        Ks2(:,:,i2) = Ktmp;
    end
 
    [res_jmksc, timeElapsed1, res_jmksc_aio,biaozhuncha,fangcha] = JMKSC_single_dataset(Ks2, Y, alphas, betas, gammas, nRepeat);
          res_jmksc_aio=res_jmksc_aio(:,ind);
    biaozhuncha=biaozhuncha(:,ind);
    fangcha=fangcha(:,ind);
    res_jmksc=res_jmksc(:,ind);
    save(['..\','metricresult\',datasetsAio{i1},'_', indicator{ind},'_.mat'],  'res_jmksc_aio','res_jmksc');
        save([datasetsAio{i1},'_', indicator{ind},'_.mat'],  'res_jmksc_aio','res_jmksc');
        end
end